package ru.tapublog.lib.samsungwallet.impl.dao;

import java.util.Set;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement(name = "ticket")
@XmlAccessorType(XmlAccessType.FIELD)
public class TicketDAO {

	@XmlRootElement(name = "head")
	@XmlAccessorType(XmlAccessType.FIELD)
	public static class Head {
		// Head
		private String version;
		private String serial;
		private String skinId;
		private boolean storable = true;
		private DateType validUntil;
		private Set<String> keywords;
		public String getVersion() {
			return version;
		}
		public void setVersion(String version) {
			this.version = version;
		}
		public String getSerial() {
			return serial;
		}
		public void setSerial(String serial) {
			this.serial = serial;
		}
		public String getSkinId() {
			return skinId;
		}
		public void setSkinId(String skinId) {
			this.skinId = skinId;
		}
		public boolean isStorable() {
			return storable;
		}
		public void setStorable(boolean storable) {
			this.storable = storable;
		}
		public DateType getValidUntil() {
			return validUntil;
		}
		public void setValidUntil(DateType validUntil) {
			this.validUntil = validUntil;
		}
		public Set<String> getKeywords() {
			return keywords;
		}
		public void setKeywords(Set<String> keywords) {
			this.keywords = keywords;
		}
		@Override
		public int hashCode() {
			final int prime = 31;
			int result = 1;
			result = prime * result
					+ ((serial == null) ? 0 : serial.hashCode());
			return result;
		}
		@Override
		public boolean equals(Object obj) {
			if (this == obj)
				return true;
			if (obj == null)
				return false;
			if (getClass() != obj.getClass())
				return false;
			Head other = (Head) obj;
			if (serial == null) {
				if (other.serial != null)
					return false;
			} else if (!serial.equals(other.serial))
				return false;
			return true;
		}
		@Override
		public String toString() {
			return "Head [version=" + version + ", serial=" + serial
					+ ", skinId=" + skinId + ", storable=" + storable
					+ ", validUntil=" + validUntil + ", keywords=" + keywords
					+ "]";
		}
	}
	private Head head = new Head();

	// View
	@XmlElement(name = "view")
	private Set<ViewElement> viewElements;

	// Alerts
	private Set<AlertDAO> alerts;

	// Partners
	private Set<PartnerDAO> partners;

	public Set<ViewElement> getViewElements() {
		return viewElements;
	}

	public void setViewElements(Set<ViewElement> viewElements) {
		this.viewElements = viewElements;
	}

	public Set<AlertDAO> getAlerts() {
		return alerts;
	}

	public void setAlerts(Set<AlertDAO> alerts) {
		this.alerts = alerts;
	}

	public Set<PartnerDAO> getPartners() {
		return partners;
	}

	public void setPartners(Set<PartnerDAO> partners) {
		this.partners = partners;
	}

	public Head getHead() {
		return head;
	}

	public void setHead(Head head) {
		this.head = head;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((alerts == null) ? 0 : alerts.hashCode());
		result = prime * result + ((head == null) ? 0 : head.hashCode());
		result = prime * result
				+ ((partners == null) ? 0 : partners.hashCode());
		result = prime * result
				+ ((viewElements == null) ? 0 : viewElements.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		TicketDAO other = (TicketDAO) obj;
		if (alerts == null) {
			if (other.alerts != null)
				return false;
		} else if (!alerts.equals(other.alerts))
			return false;
		if (head == null) {
			if (other.head != null)
				return false;
		} else if (!head.equals(other.head))
			return false;
		if (partners == null) {
			if (other.partners != null)
				return false;
		} else if (!partners.equals(other.partners))
			return false;
		if (viewElements == null) {
			if (other.viewElements != null)
				return false;
		} else if (!viewElements.equals(other.viewElements))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "TicketDAO [head=" + head + ", viewElements=" + viewElements
				+ ", alerts=" + alerts + ", partners=" + partners + "]";
	}



}
